package com.lx.zy.common.utils;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @program: zy-vue
 * @description: 安全服务工具类
 * @author: Lx
 * @create: 2019-10-18 22:58
 **/
public class SecurityUtils
{
    /**
     * 获取 Authentication
     *
     * @return
     */
    public static Authentication getAuthentication()
    {
        return SecurityContextHolder.getContext().getAuthentication();
    }

    /**
     * 是否为管理员
     *
     * @param userId 用户ID
     * @return 结果
     */
    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }
}
